package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Tongzhileixing;
import com.ruoyi.system.service.ITongzhileixingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 通知类型Controller
 * 
 * @author ruoyi
 * @date 2024-08-10
 */
@RestController
@RequestMapping("/system/tongzhileixing")
public class TongzhileixingController extends BaseController
{
    @Autowired
    private ITongzhileixingService tongzhileixingService;

    /**
     * 查询通知类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:tongzhileixing:list')")
    @GetMapping("/list")
    public TableDataInfo list(Tongzhileixing tongzhileixing)
    {
        startPage();
        List<Tongzhileixing> list = tongzhileixingService.selectTongzhileixingList(tongzhileixing);
        return getDataTable(list);
    }

    /**
     * 导出通知类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:tongzhileixing:export')")
    @Log(title = "通知类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Tongzhileixing tongzhileixing)
    {
        List<Tongzhileixing> list = tongzhileixingService.selectTongzhileixingList(tongzhileixing);
        ExcelUtil<Tongzhileixing> util = new ExcelUtil<Tongzhileixing>(Tongzhileixing.class);
        util.exportExcel(response, list, "通知类型数据");
    }

    /**
     * 获取通知类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:tongzhileixing:query')")
    @GetMapping(value = "/{tzlxId}")
    public AjaxResult getInfo(@PathVariable("tzlxId") Long tzlxId)
    {
        return success(tongzhileixingService.selectTongzhileixingByTzlxId(tzlxId));
    }

    /**
     * 新增通知类型
     */
    @PreAuthorize("@ss.hasPermi('system:tongzhileixing:add')")
    @Log(title = "通知类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Tongzhileixing tongzhileixing)
    {
        return toAjax(tongzhileixingService.insertTongzhileixing(tongzhileixing));
    }

    /**
     * 修改通知类型
     */
    @PreAuthorize("@ss.hasPermi('system:tongzhileixing:edit')")
    @Log(title = "通知类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Tongzhileixing tongzhileixing)
    {
        return toAjax(tongzhileixingService.updateTongzhileixing(tongzhileixing));
    }

    /**
     * 删除通知类型
     */
    @PreAuthorize("@ss.hasPermi('system:tongzhileixing:remove')")
    @Log(title = "通知类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tzlxIds}")
    public AjaxResult remove(@PathVariable Long[] tzlxIds)
    {
        return toAjax(tongzhileixingService.deleteTongzhileixingByTzlxIds(tzlxIds));
    }
}
